rm(list = ls())
library(rootSolve)
A <- 5
alpha <- 0.36
delta <- 0.075
s <- 0.36
n <- 0

# y = A*k^alpha
solow <- function(k) s*A*(k^alpha) - (n+delta)*k
curve(solow, 0,200)
kss <- uniroot(solow, c(100,200))$root
# kss <- (s*A/(n+delta))^(1/(1-alpha))

solowt <- function(k) k + s*A*(k^alpha) - (n+delta)*k
k0 <- 20
kt <- numeric(200)
for (i in 1:200) {
  kt[i] <- k0 <- solowt(k0)
  print(k0)
}

picdata <- data.frame(tt = 1:length(kt),kt = kt, yt = A*kt^alpha)
ggplot(picdata, aes(x = tt, y = kt)) + geom_point(shape = 1) +
  geom_point(aes(y = yt)) +
  theme_bw()
